#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'
const int maxn = 1e6 + 100;
/**
 * 区间筛法
 */
bool small[maxn];//保存1-sqrt(b)内的素数
bool large[maxn];//保存 [a,b]里的素数x 即 large[x-a]

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int a, b;
    cin >> a >> b;
    if (a < 2)a = 2;
    int m = sqrt(b) + 1;
    fill(small + 2, small + m + 1, true);
    fill(large, large + b - a + 1, true);

    for (int i = 2; i <= m; i++) {//sqrt(n)
        if (small[i]) {
            for (int j = 2 * i; j <= m; j += i) {
                small[j] = false;
            }
            for (int j = max(ceil(1.0*a/i) * i, 2 * i); j <= b; j += i) {
                large[j - a] = false;
            }
        }
    }
    cout << count(large, large + b - a + 1, true) << endl;
    return 0;
}
